﻿using System;

namespace Actya.Core.Infrastructure.Logging
{
	public class DebugLogger : ILogger
	{
		private readonly Type _type;

		public DebugLogger(Type type)
		{
			_type = type;
		}

		public bool IsDebugEnabled
		{
			get { return true; }
		}

		private string CreateLogMessage(string format, params object[] args)
		{
			var message = args.Length > 0 ? string.Format(format, args) : format;
			return string.Format("[{0}] {1} - {2}",
			                     DateTime.Now.ToString("o"),
			                     _type, message);
		}

		public void Error(string format, params object[] args)
		{
			System.Diagnostics.Debug.WriteLine(CreateLogMessage(format, args), "ERROR");
		}

		public void Error(Exception exception)
		{
			System.Diagnostics.Debug.WriteLine(CreateLogMessage(exception.ToString()), "ERROR");
		}

		public void Debug(string format, params object[] args)
		{
			System.Diagnostics.Debug.WriteLine(CreateLogMessage(format, args), "DEBUG");
		}

		public void Info(string format, params object[] args)
		{
			System.Diagnostics.Debug.WriteLine(CreateLogMessage(format, args), "INFO");
		}
		public void Warn(string format, params object[] args)
		{
			System.Diagnostics.Debug.WriteLine(CreateLogMessage(format, args), "WARN");
		}
	}
}
